package com.app.bimo.library_db.helper;


import com.app.bimo.library_db.ADConfigData;
import com.app.bimo.library_db.ADConfigResultData;
import com.app.bimo.library_db.dao.ADConfigResultDataDao;
import com.app.bimo.library_db.dao.DaoSession;

public class AdHelper {
    private static volatile AdHelper sInstance;
    private static DaoSession daoSession;
    private static ADConfigResultDataDao adConfigResultDataDao;

    public static AdHelper getsInstance() {
        if (sInstance == null) {
            synchronized (AdHelper.class) {
                if (sInstance == null) {
                    sInstance = new AdHelper();
                    daoSession = DaoDbHelper.getInstance().getSession();
                    adConfigResultDataDao = daoSession.getADConfigResultDataDao();
                }
            }
        }
        return sInstance;
    }

    /**
     * 保存用户
     */
    public void save(ADConfigResultData adConfigResultData) {
        adConfigResultDataDao.deleteAll();
        adConfigResultDataDao.save(adConfigResultData);
        adConfigResultDataDao.detachAll();
    }

    /**
     * 根据用户名查询用户信息
     *
     * @return
     */
    public ADConfigResultData findAdConfig() {
        return adConfigResultDataDao.queryBuilder().unique();
    }

    /**
     * 根据用户名查询用户信息
     *
     * @return
     */
    public ADConfigData getAdBookshelfBanner() {
        ADConfigResultData data = adConfigResultDataDao.queryBuilder().unique();
        if (data == null) {
            return null;
        } else {
            return data.getAdBookshelfBanner();
        }
    }

    public ADConfigData getAdBookshelf() {
        ADConfigResultData data = adConfigResultDataDao.queryBuilder().unique();
        if (data == null) {
            return null;
        } else {
            return data.getAdBookshelf();
        }
    }

    /******/
    public ADConfigData getAdReadBanner() {
        ADConfigResultData data = adConfigResultDataDao.queryBuilder().unique();
        if (data == null) {
            return null;
        } else {
            return data.getAdReadBanner();
        }
    }

    public ADConfigData getAdReadBottom() {
        ADConfigResultData data = adConfigResultDataDao.queryBuilder().unique();
        if (data == null) {
            return null;
        } else {
            return data.getAdReadBottom();
        }
    }

    public ADConfigData getAdReadTop() {
        ADConfigResultData data = adConfigResultDataDao.queryBuilder().unique();
        if (data == null) {
            return null;
        } else {
            return data.getAdReadTop();
        }
    }

    public ADConfigData getAdReadPopup() {
        ADConfigResultData data = adConfigResultDataDao.queryBuilder().unique();
        if (data == null) {
            return null;
        } else {
            return data.getAdReadPopup();
        }
    }

    public ADConfigData getAdSearchResult() {
        ADConfigResultData data = adConfigResultDataDao.queryBuilder().unique();
        if (data == null) {
            return null;
        } else {
            return data.getAdSearchResult();
        }
    }

    public ADConfigData getAdSearch() {
        ADConfigResultData data = adConfigResultDataDao.queryBuilder().unique();
        if (data == null) {
            return null;
        } else {
            return data.getAdSearch();
        }
    }

    public ADConfigData getAdDownload() {
        ADConfigResultData data = adConfigResultDataDao.queryBuilder().unique();
        if (data == null) {
            return null;
        } else {
            return data.getAdDownload();
        }
    }

    public ADConfigData getAdNovel() {
        ADConfigResultData data = adConfigResultDataDao.queryBuilder().unique();
        if (data == null) {
            return null;
        } else {
            return data.getAdNovel();
        }
    }

    public ADConfigData getAdStartup() {
        ADConfigResultData data = adConfigResultDataDao.queryBuilder().unique();
        if (data == null) {
            return null;
        } else {
            return data.getAdStartup();
        }
    }

    public ADConfigData getAdReadPage() {
        ADConfigResultData data = adConfigResultDataDao.queryBuilder().unique();
        if (data == null) {
            return null;
        } else {
            return data.getAdReadPage();
        }
    }





}
